const express = require('express');
const db = require('../uilit/mysql');

const router=express.Router();

router.post('/selectAddress',(req,res)=>{
    const sql1=`select * from province`;
    const sql2=`select * from city`;
    const sql3=`select * from area`;
    db.query(sql1,(err1,data1)=>{
        if(err1){
            console.log(err1);
        }else{
            db.query(sql2,(err2,data2)=>{
                if(err2){
                    console.log(err2);
                }else{
                    db.query(sql3,(err3,data3)=>{
                        if(err3){
                            console.log(err3);
                        }else{
                            res.send({province:data1,city:data2,area:data3});
                        }
                    })
                }
            })
        }
    })
})

module.exports=router;
